import 'package:flutter/material.dart';

class EgDismissible extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<String> items = new List<String>.generate(30, (i) => "列表项  ${i + 1}");

    return new Scaffold(
      appBar: new AppBar(
        title: new Text("滑动删除组件"),
      ),
      body: new Container(
        child: new ListView.builder(
          itemBuilder: (context, index) {
            var item = items[index];
            return new Dismissible(
                key: new Key(item),
                onDismissed: (direction) {
                  items.removeAt(index);
                  Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("$item  被删除了")));
                },
                child: new ListTile(
                  title: new Text(item),
                ));
          },
          itemCount: items.length,
        ),
      ),
    );
  }
}
